<!--头部公共部分-->
{include file="common/header" /}
<div style="padding:15px;font-size: 12px;">
    <div class="layui-tab-item layui-show">
        <form class="layui-form layui-form-pane">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label"><span style="color: red;">*</span>校区：</label>
                    <div class="layui-input-inline">
                        <select name="campus_id"  lay-verify="required" lay-search="">
                            <option value="">请选择校区</option>
                            {foreach name="campus" id="v"}
                            <option value="{$v.id}">{$v.campus_name}</option>
                            {/foreach}
                        </select>
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label"><span style="color: red;">*</span>节数：</label>
                    <div class="layui-input-inline">
                        <input type="text" name="week" lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>



            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label"><span style="color: red;">*</span>开始时间：</label>
                    <div class="layui-input-inline">
                        <input type="text" id="s_time" name="start_time" lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label class="layui-form-label"><span style="color: red;">*</span>结束时间：</label>
                    <div class="layui-input-inline">
                        <input type="text" id="e_time" name="end_time" lay-verify="required" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>
            <!--
            <div class="layui-form-item">
                <label class="layui-form-label"><span style="color: red;">*</span>类型</label>
                <div class="layui-input-block">
                    <input type="radio" name="type" value="1" class="layui-input" title="工作日"checked/>
                    <input type="radio" name="type" value="0" class="layui-input" title="周末"/>
                </div>
            </div>
            -->
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <input class="layui-btn layui-btn-normal" lay-submit lay-filter="from" id="sub" value="保存" readonly>
                </div>
            </div>
        </form>
    </div>
</div>
<!--底部公共部分-->
{include file="common/footer" /}


<script>
    layui.use(['jquery','form','element','layer','laydate'], function(){
        let $ = layui.jquery,
            laydate = layui.laydate,
            element = layui.element,
            layer = layui.layer,
            form = layui.form;

        //时间选择器
        laydate.render({
            elem: '#s_time'
            ,type: 'time'
            ,format: 'H:m:s'
            ,trigger: 'click'
        });

        //时间选择器
        laydate.render({
            elem: '#e_time'
            ,type: 'time'
            ,format: 'H:m:s'
            ,trigger: 'click'
        });

        form.on('submit(from)', function (data) {
            let field = data.field;
            $.ajax({
                type: 'post',
                url: '{:url("Schooltime/add")}',
                data: field,
                success: function (result) {
                    layer.msg(result.msg);
                    if (result.code === 1) {
                        setTimeout(function () {
                            var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                            parent.layer.close(index); //再执行关闭
                            parent.location.reload();
                        }, 2000);
                    }
                }
            });
        });
    });
</script>
